package com.org.gsc.menusdemo;

import android.app.Activity;
import android.os.Bundle;
import android.support.v4.widget.DrawerLayout;
import android.view.View;
import android.widget.AdapterView;
import android.widget.ArrayAdapter;
import android.widget.ListView;

/**
 * Created by qundui on 2017/6/26.
 */

public class DrawerLayoutDemo extends Activity implements DrawerLayout.DrawerListener {
    private DrawerLayout mDrawerLayout;
    private ListView mListView;
    private String[] mdatas={"A","B","C","D","E","F"};

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.drawtest);
        mDrawerLayout= (DrawerLayout) findViewById(R.id.dl);
        mListView= (ListView) findViewById(R.id.left_drawer);
        mListView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
            @Override
            public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
               mDrawerLayout.closeDrawer(mListView);
            }
        });
        mListView.setAdapter(new ArrayAdapter<String>(this,android.R.layout.simple_list_item_1,android.R.id.text1,mdatas));
        mDrawerLayout.setDrawerListener(this);
    }
    @Override
    public void onDrawerSlide(View drawerView, float slideOffset) {
        System.out.println("onDrawerSlide");
    }

    @Override
    public void onDrawerOpened(View drawerView) {
        System.out.println("onDrawerOpened");
    }

    @Override
    public void onDrawerClosed(View drawerView) {
        System.out.println("onDrawerClosed");
    }

    @Override
    public void onDrawerStateChanged(int newState) {
        System.out.println("onDrawerStateChanged"+newState);
    }
}
